﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace StudentExceptions
{
    enum Gender
    {
        Male,
        Female,
        undefined
    }

    class Student
    {
        private int age;
        private Gender gender;
        private string name;
        private byte clas;

        public Student()
        {
            this.Age = 7;
            this.Gender = Gender.Male;
            this.Name = "Example name";
            this.Clas = 1;
        }

        public Student(int age, Gender gender, string name, byte clas)
        {
            this.Age = age;
            this.Gender = gender;
            this.Name = name;
            this.Clas = clas;
        }

        public int Age
        {
            get
            {
                return age;
            }
            set
            {
                if (value > 6 && value < 18)
                {
                    age = value;
                }
                else
                {
                    throw new InvalidStudentException(string.Format("{0} is illegal age for student.Must be between 7 and 18", value));
                }
            }
        }

        public Gender Gender
        {
            get
            {
                return gender;
            }
            set
            {
                if (value == Gender.Male || value == Gender.Female)
                {
                    gender = value;
                }
                else
                {
                    throw new InvalidStudentException("This is not a legal gender. Must be Male or Female");
                }
            }
        }

        public string Name
        {
            get
            {
                return name;
            }
            set
            {
                if (value.Length > 10 && value.Length < 50)
                {
                    name = value;
                }
                else
                {
                    throw new InvalidStudentException(string.Format("{0} is illegal name length. Must be between 10 and 50 characters", value)); 
                }
            }
        }

        public byte Clas
        {
            get
            {
                return clas;
            }
            set
            {
                if (value > 0 && value < 12)
                {
                    clas = value;
                }
                else
                {
                    throw new InvalidStudentException(string.Format("{0} is illegal value for class. Must be between 1 and 11", value));
                }
            }
        }
    }
}
